<?php


namespace App\Api\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class Blanace extends Model
{
    use HasFactory;
    protected $guarded = [];
    protected $table ='cmc_blanace';

    public static function saveData($data,$where = [])
    {
        if (!empty($where) && is_array($where)){
            return self::query()->where($where)->update($data);
        }
        return self::query()->create($data);
    }

    public static function totalTop($memberId)
    {
        return self::query()->where('member_id',$memberId)
            ->where('status',1)
            ->sum('price');
    }
}
